<h2>Add Volume</h2>
<hr/>
<p>To add a new Volume, enter valid information into the following fields:<br />
NB: All fields marked with an asterisk are required '*'</p>
<center>
<div class="errorval"><?php echo validation_errors(); ?>
<?php echo $error; ?></div>

<table>
<?php echo form_open('admin/catalogue_management/addVolume/'); ?>
<tr>
	<th align="right" width=30%>*Accession Number:</th>
	<td><?php echo form_input('access_id', $access_id); ?></td>
</tr>
<tr>
	<th align="right">*Call Number:</th>
	<td><?php echo form_input('call_number', set_value('call_number')); ?></td>
</tr>
<tr>
	<th align="right">*Title:</th>
	<td><?php echo form_input('title', set_value('title')); ?></td>
</tr>
<tr>
	<th align="right">Publisher Name:</th>
	<td><?php echo form_input('publisher_name', set_value('publisher_name')); ?></td>
</tr>
<tr>
	<th align="right">Publisher Year:</th>
	<td><?php echo form_input('publisher_date', set_value('publisher_date')); ?></td>
</tr>
<tr>
	<th align="right">ISBN:</th>
	<td><?php echo form_input('isbn', set_value('isbn')); ?><p name="isbn_error"></p></td>
</tr>
<tr>
	<th align="right">*Location:</th>
	<?php
	$options = array();
	
	foreach ($locations as $location)
		$options[$location->location_id] = $location->location_name;
	
	?>
	<td colspan=2><?php echo form_dropdown('location_id', $options); ?></td>
</tr>
<tr>
	<th align="right">*Catalogue Date:</th>
	<td><?php echo form_input('catalogue_date', date('Y-m-d')); ?></td>
</tr>
<tr>
	<th class="tablehead" align="right">Actions</th>
	<td><input class="submit" type="submit" value="Submit"/></td>
</tr>
<?php echo form_close(); ?>
</table>
</center>

<script type="text/javascript">
$(document).ready(function() {
		//$( '[name="publisher_date"]' ).datepicker({ dateFormat: 'yy', changeYear: true });
		$( '[name="catalogue_date"]' ).datepicker({ dateFormat: 'yy-mm-dd', changeMonth: true, changeYear: true });
		addAutocomplete('[name="call_number"]', '<?php echo site_url('admin/jquery/autocomplete/tbl_volume/call_number'); ?>');
		addAutocomplete('[name="title"]', '<?php echo site_url('admin/jquery/autocomplete/tbl_volume/title'); ?>');
		addAutocomplete('[name="publisher_name"]', '<?php echo site_url('admin/jquery/autocomplete/tbl_volume/publisher_name'); ?>');
		
		$("[name=isbn]").keyup( function(){
			var isbn = $("[name=isbn]").val();
			if ( !validateISBN(isbn) )
				$('[name=isbn_error]').html("Invalid ISBN");
				
			else
				$('[name=isbn_error]').html("");
		});
});
</script>
